package org.ndx.majick.ui.object;

import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.util.Locale;

import org.ndx.majick.properties.Property;
import org.ndx.majick.properties.util.PropertyUtils;
import org.ndx.majick.ui.IPropertyUIMetadata;

public class ObjectPropertyMetadata implements IPropertyUIMetadata {
	/**
	 * Support, since these metadatas are beans
	 */
	protected transient final PropertyChangeSupport support = new PropertyChangeSupport(this);

	/**
	 * By setting this property to true, user assume this property can't be edited by hand. As a consequence, when returning an editor for such a property,
	 * it is always disabled.
	 */
	private final Property<Boolean> readOnly = PropertyUtils.create(Boolean.class, ObjectPropertyMetadata.class.getName()+".readOnly", support, false);
	
	
	public final Property<Locale> locale = PropertyUtils.create(Locale.class, ObjectPropertyMetadata.class.getName()+".locale", support, Locale.getDefault());

	public Property<Boolean> getReadOnly() {
		return readOnly;
	}

	public void addPropertyChangeListener(PropertyChangeListener listener) {
		support.addPropertyChangeListener(listener);
	}

	public void removePropertyChangeListener(PropertyChangeListener listener) {
		support.removePropertyChangeListener(listener);
	}

	public Property<Locale> getLocale() {
		return locale;
	}
}
